package com.dries.portal.module.coupon.utils.convert;

import cn.hutool.json.JSONUtil;
import com.dries.portal.module.coupon.entity.Template;
import com.dries.portal.module.coupon.vo.CouponTemplateSDK;
import com.dries.portal.module.coupon.vo.TemplateRule;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;

/**
 * @Description:
 * @Author ZSY
 * @createTime 2020/7/28 10:27
 */
@Slf4j
public class Template2CouponTemplateSDKConvert {

    public static CouponTemplateSDK convert(Template template){

        CouponTemplateSDK sdk = new CouponTemplateSDK();
        BeanUtils.copyProperties(template, sdk);

        //        sdk.setCategory(template.getCategory().getCode());
        //        sdk.setProductLine(template.getProductLine().getCode());
        //        sdk.setTarget(template.getTarget().getCode());
        sdk.setRule(JSONUtil.toBean(template.getRule(), TemplateRule.class));
        return sdk;

    }

}
